//引入刚才的http.js文件
import https from './https.js';

let decode = true ? '' : '?yapi=jiyang';// 加密状态
export default {
    // 导出表格
    /**
     * 
     * @param {*} jsonData 表格数据
     * @param {*} tit 表格头
     * @param {*} excel 表格名称
     * @returns 
     */
    exportData: function (jsonData, tit, excel) {
        if (!jsonData.length) {
            return false;
        }

        // 表格的列标题 如果出现科学技术法或者其他格式 使用 \t
        let title = tit;
        jsonData.map((item, index) => {
            let obj = {};
            for (const key in item) {
                const element = item[key];
                obj[index] = element;
                for (let i in obj) {
                    title += `${obj[i]},`;
                }
            }
            title += "\n";
        });
        // encodeURIComponent 解决中文乱码
        let url =
            "data:text/csv;charset=utf-8,\ufeff" + encodeURIComponent(title);
        // 创建a标签
        let link = document.createElement("a");
        link.href = url;
        link.download = `${excel}${new Date().toJSON()}.xls`;
        link.click();
        link.remove();
    },
    login: function (params) {
        return https.post('/api/auth/guild_login' + decode, params)
    },
    // 获取验证码
    send_code: function (params) {
        return https.post('/api/system/send_code' + decode, params)
    },
    // 公会经营
    get_out_count: function (params) { // 退出条数
        return https.get('/api/guild_backend/get_out_count' + decode, params)
    },
    get_join_count: function (params) { // 获取申请加入条数
        return https.get('/api/guild_backend/get_join_count' + decode, params)
    },
    get_artilces: function (params) { // 获取文章列表
        return https.get('/api/guild_backend/get_artilces' + decode, params)
    },
    get_artilce_detail: function (params) { // 获取文章详情
        return https.get('/api/guild_backend/get_artilce_detail' + decode, params)
    },
    income_rank: function (params) { // 聊天室收入top10 周榜
        return https.get('/api/guild_backend/income_rank' + decode, params)
    },
    week_rank: function (params) { // 订单数据top10 周榜
        return https.get('/api/guild_backend/week_rank' + decode, params)
    },
    reward_rank: function (params) { // 打赏收入top10 周榜
        return https.get('/api/guild_backend/reward_rank' + decode, params)
    },
    amount_water: function (params) { // 昨日今日订单打赏流水
        return https.get('/api/guild_backend/amount_water' + decode, params)
    },
    income_person: function (params) { // 昨日今日订单打赏人数
        return https.get('/api/guild_backend/income_person' + decode, params)
    },

    // 数据报表
    guild_rooms: function (params) { // 聊天室数据
        return https.get('/api/guild_backend/guild_rooms' + decode, params)
    },
    reward_list: function (params) { // 打赏数据
        return https.post('/api/guild_backend/reward_list' + decode, params)
    },
    order_list: function (params) { // 订单数据
        return https.get('/api/guild_backend/order_list' + decode, params)
    },
    get_new_msgs: function (params) { // 新用户推荐
        return https.get('/api/guild_backend/get_new_msgs' + decode, params)
    },
    get_msgs: function (params) { // 私聊数据
        return https.get('/api/guild_backend/get_msgs' + decode, params)
    },

    // 大神管理
    get_members: function (params) { // 大神列表
        return https.get('/api/guild_backend/get_members' + decode, params)
    },
    take_orders: function (params) { // 接单数据
        return https.get('/api/guild_backend/take_orders' + decode, params)
    },
    invite_anchor: function (params) { // 邀约主播
        return https.post('/api/guild_backend/invite_anchor' + decode, params)
    },
    invite_list: function (params) { // 公会邀约/入会审核列表
        return https.get('/api/guild_backend/invite_list' + decode, params)
    },
    approve: function (params) { // 入会列表 通过/拒绝
        return https.post('/api/guild_backend/approve' + decode, params)
    },
    cancel_anchor: function (params) { // 公会解约
        return https.get('/api/guild_backend/cancel_anchor' + decode, params)
    },
    out_list: function (params) { // 公会申请退出列表
        return https.get('/api/guild_backend/out_list' + decode, params)
    },
    apply_out: function (params) { // 公会申请退出 1同意 0拒绝
        return https.post('/api/guild_backend/apply_out' + decode, params)
    },

    // 房间管理
    room_list: function (params) { // 公会关联房间列表
        return https.post('/api/guild_backend/room_list' + decode, params)
    },
    room_update: function (params) { // 公会关联房间信息更新
        return https.post('/api/guild_backend/room_update' + decode, params)
    },
    close_room: function (params) { // 关闭房间
        return https.post('/api/guild_backend/close_room' + decode, params)
    },
    room_open: function (params) { // 开启房间
        return https.post('/api/guild_backend/room_open' + decode, params)
    },
    room_operate_log: function (params) { // 公会关联房间日志
        return https.get('/api/guild_backend/room_operate_log' + decode, params)
    },
    income: function (params) { // 公会关联房间收入 锁死15条
        return https.get('/api/guild_backend/income' + decode, params)
    },
    room_gift_log: function (params) { // 公会关联房间打赏日志
        return https.get('/api/guild_backend/room_gift_log' + decode, params)
    },
    kickout_log: function (params) { // 公会关联房间封禁记录
        return https.get('/api/guild_backend/kickout_log' + decode, params)
    },
    income_day: function (params) { // 公会关联房间收入记录按天下的小时
        return https.get('/api/guild_backend/income_day' + decode, params)
    },
    room_channel: function (params) { // 公会后台频道列表
        return https.get('/api/guild_backend/room_channel' + decode, params)
    },

    // 公会设置
    guild_config: function (params) { // 公会信息
        return https.get('/api/guild_backend/guild_config' + decode, params)
    },
    update_guild: function (params) { // 修改公会信息
        return https.post('/api/guild_backend/update_guild' + decode, params)
    },

    // 文件上传
    upload: function (params) {
        return https.post('/api/file/upload_guild' + decode, params)
    },
    a: `this.$api.get_artilces(params).then((res) => {
        if (res.code == 200) {

        }
    })`
}
// guild
// 数据报表 聊天室数据 => 没有流水
// 昨日今日订单打赏流水 => /api/guild_backend/amount_water
// 昨日今日订单打赏人数 => /api/guild_backend/income_person
// 打赏记录 => 
// 房间列表 => 
// 开启房间 => 
// 房间编辑 => 名称 /api/room/update
// 关闭房间 => /api/room/close_room
// 房间日志 => /api/room/operate_dolog
// 收入统计 => /api/room/operate_dolog || /api/room/income_day
// 封禁记录 => /api/room/kickout_log